----------------------
-- Non Tangibles... --
----------------------
function buy_Add100StatPoints(ply)
	ply:AddStatPoints(100)
end

function buy_Add1000StatPoints(ply)
	ply:AddStatPoints(1000)
end

function buy_BuyTeamBack(player)
	SendMessageToPlayerChat(player, "You bought your team back from the dead, good job")
	for _,ply in pairs(team.GetPlayers(TEAM_LIVING)) do
		SendMessageToPlayerChat(ply, player:GetName() .. " bought your teammates back from the dead!")
	end
	for _,ply in pairs(team.GetPlayers(TEAM_SPEC)) do
		ply:SetTeam(TEAM_LIVING)
		ply:KillSilent()
		SendMessageToPlayerChat(ply, player:GetName() .. " bought you back from the dead, say thanks!")
	end
end

function buy_Turret_Mediocre(ply)
	local tr = ply:GetEyeTrace()
			
	npc = ents.Create ("npc_turret_floor")
	npc:SetPos(tr.HitPos)
	npc:SetAngles(Angle(0, ply:GetAngles().y, 0))

	npc:Spawn()
	npc:SetMaxHealth(300)
	npc:SetHealth(300)
	--npc:SetCollisionGroup (3)
	npc:SetCurrentWeaponProficiency( WEAPON_PROFICIENCY_POOR )
	
	-- Turrets initially hate EVERYTHING NPC
	npc:AddRelationship("npc_* D_HT 100")
	
	-- Turrets LIKE powercores and players!
	local powercore = ents.FindByClass("inv_powercore")[1]
	npc:AddEntityRelationship(powercore, D_LI, 100 )
	npc:AddRelationship("player D_LI 100")
	
	npc:SetOwner(ply)
end

function buy_Turret_SlightlyBetter(ply)
	local tr = ply:GetEyeTrace()
			
	npc = ents.Create ("npc_turret_floor")
	npc:SetPos(tr.HitPos)
	npc:SetAngles(Angle(0, ply:GetAngles().y, 0))

	npc:Spawn()
	npc:SetMaxHealth(300)
	npc:SetHealth(300)
	--npc:SetCollisionGroup (3)
	npc:SetCurrentWeaponProficiency( WEAPON_PROFICIENCY_GOOD )
	
	-- Turrets initially hate EVERYTHING NPC
	npc:AddRelationship("npc_* D_HT 100")
	
	-- Turrets LIKE powercores and players!
	local powercore = ents.FindByClass("inv_powercore")[1]
	npc:AddEntityRelationship(powercore, D_LI, 100 )
	npc:AddRelationship("player D_LI 100")
	
	npc:SetOwner(ply)
	
	-- Slightly better turret cant fall
	constraint.Weld(npc,ents.FindByClass("worldspawn")[1],0,0,0,true) --And weld the manhack to the entity
end



----------------------
-- LIST OF BUYABLES --
----------------------
INV_BUYABLES = {}
--                  Name           Cost    Entity Name/Function     Short Description                                   type  BuyOnce 
INV_BUYABLES[1] = {"Training Pistol", 0, "inv_trainingpistol", "The L plate of pistols", "weapon", true, nil }
INV_BUYABLES[2] = {"Auto Pistol", 1000, "inv_autopistol", "An autofiring pistol with a slightly faster refiring rate", "weapon", true, nil}
INV_BUYABLES[3] = {"100 Stat points", 8000, buy_Add100StatPoints, "Boost your stat points for a sum of money", "function", false, nil }
INV_BUYABLES[4] = {"1000 Stat points", 60000, buy_Add1000StatPoints, "Buy 900, get 100 free!", "function", false, nil }
INV_BUYABLES[5] = {"Medicine Cabinet", 5000, "inv_medicinecabinet", "Heal yourself and others!", "physical", false, nil }
INV_BUYABLES[6] = {"SMG Level 1", 4000, "inv_smglvl1", "An SMG, Level 1 Stats", "weapon", true, nil}
INV_BUYABLES[7] = {"SMG Level 2", 7000, "inv_smglvl2", "An SMG, Level 2 Stats; Better accuracy and a more damaging shot", "weapon", true, {6} }
INV_BUYABLES[8] = {"Pain Killers", 10000, "inv_painkillers", "Single use 'weapon' that heals you to full health", "weapon", true, nil }
INV_BUYABLES[9] = {"SMG Level 3", 12000, "inv_smglvl3", "An SMG, Level 3 Stats; More Damage, Bigger clip and faster fire rate", "weapon", true, {7} }
INV_BUYABLES[10] = {"357 Level 1", 15000, "inv_357lvl1", "Bog standard 357", "weapon", true, nil }
INV_BUYABLES[11] = {"357 Level 2", 24000, "inv_357lvl2", "A bit faster with much more damage", "weapon", true, {10} }
INV_BUYABLES[12] = {"357 Level 3", 32000, "inv_357lvl3", "Even faster, More damage and accuracy is better", "weapon", true, {11} }
INV_BUYABLES[13] = {"Buy team back", 40000, buy_BuyTeamBack, "Buy your team members back from the dead!", "function", false, nil }
INV_BUYABLES[14] = {"Crossbow Level 1", 30000, "inv_xbowlvl1", "A slow, Sorta Accurate high-damage weapon", "weapon", true, nil }
INV_BUYABLES[15] = {"Crowbar", 5500, "weapon_crowbar", "A bar of crow", "weapon", true, nil }
INV_BUYABLES[16] = {"Crossbow Level 2", 60000, "inv_xbowlvl2", "A slowish, Damn Accurate high-damage weapon", "weapon", true, {14} }
INV_BUYABLES[17] = {"Crossbow Level 3", 100000, "inv_xbowlvl3", "A relativly fast, very accurate sniper weapon", "weapon", true, {16} }
INV_BUYABLES[18] = {"Mediocre Turret", 9000, buy_Turret_Mediocre, "A turret that aims as good as a baby, it is also knocked over VERY easy and doesn't attack combine", "function", false, nil }
INV_BUYABLES[19] = {"Slightly Better Turret", 15000, buy_Turret_SlightlyBetter, "A turret that aims slightly better and can not die or fall over, however it still does not attack combine!", "function", false, nil }
INV_BUYABLES[20] = {"Barrier creation gun", 75000, "inv_barriergun", "Creates barriers that you can use for cover", "weapon", true, nil }
INV_BUYABLES[21] = {"Silly Gun", 9000000, "inv_sillygun", "Put simply there is no weapon more silly", "weapon", true, nil }
INV_BUYABLES[22] = {"Shotgun Level 1", 10000, "inv_shotgunlvl1", "Very powerful at close range, can be made good at long range with a spread upgrade", "weapon", true, nil }
INV_BUYABLES[23] = {"Shotgun Level 2", 12000, "inv_shotgunlvl2", "Twice as much damage, more spread, faster", "weapon", true, {22} }
INV_BUYABLES[24] = {"Shotgun Level 3", 15000, "inv_shotgunlvl3", "Even better", "weapon", true, {23} }


